package com.fu.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author 付大大
 * @description
 * @create 2021-01-24 17:25
 */
@WebServlet("/servletDemo04")
public class ServletDemo04 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String news = "这是一条很火爆的新闻";

        /*设置缓存时间*/
        resp.setDateHeader("Expires", System.currentTimeMillis() + (1 * 60 * 60 * 1000));
        resp.setContentType("text/html;charset=UTF-8");
        resp.getWriter().write(news);
        System.out.println("aaaa");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
